package abstract

import (
	"encoding/json"
	"ycoem/lib/db"
)

func RedisSave(tableName string, logistics interface{}) (err error) {

	b, err := json.Marshal(logistics)
	if err != nil {
		return
	}
	err = db.Set(tableName, string(b))
	return
}

func RedisGet(tableName string, logistics interface{}) (err error) {
	str := db.Get(tableName)

	if str == "" {
		return
	}
	err = json.Unmarshal([]byte(str), logistics)
	if err != nil {
		return
	}
	return
}
